package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"tupu-go/config"
	"tupu-go/pkg/database"
)

func main() {
	err := config.InitConfig()
	if err != nil {
		fmt.Println(err)
		return
	}
	err = database.InitDB(config.Global.DMDatabase)
	if err != nil {
		fmt.Println(err)
		return
	}
	err = database.InitNebulaORM(config.Global.NebulaConfig)
	if err != nil {
		fmt.Println(err)
		return
	}
	defer database.Close()

	r := gin.Default()
	r.GET("/", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "Hello, World!",
		})
	})

	RegisterAPIRoutes(r) //注册路由

	r.Run(fmt.Sprintf(":%d", config.Global.Server.Port))
}
